package org.malred.jetpackcomposebasic

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import org.malred.jetpackcomposebasic.ui.theme.JetpackComposeBasicTheme

class MainActivity03 : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MessageCard(Message("androdid", "jetpack compose"))
        }
    }

    @Composable // compose 控件
    fun MessageCard(msg: Message) {
        Row {
            Image(
                painter = painterResource(id = R.drawable.test),
                // 无障碍模式下, 会语言读出这个描述文本
                contentDescription = ""
            )
            // column: vertical垂直排列
            Column {
                // compose: 文本控件
                Text(text = msg.author)
                Text(text = msg.body)
            }
        }
    }
}
